﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using OnlineMealOrdering.Common;

namespace OnlineMealOrdering.Extends
{
    public class MvcFileHelper
    {
        private static readonly string FilesKeyName = "UploadImageFiles";

        public static void AddFile(TempDataDictionary tempData, FileSavingInfo fileData)
        {
            TempDataHelper.AddObjectToList(tempData, FilesKeyName, fileData);
        }
        public static void RemoveSomeFiles<T>(TempDataDictionary tempData, Func<T, bool> selector)
        {
            TempDataHelper.RemoveItemFromList(tempData, FilesKeyName, selector);
        }
        public static void CleanAllFiles(TempDataDictionary tempData)
        {
            TempDataHelper.RemoveObject(tempData, FilesKeyName);
        }
        public static List<FileSavingInfo> GetFiles(TempDataDictionary tempData)
        {
            return TempDataHelper.GetAllObjectsFromList<FileSavingInfo>(tempData, FilesKeyName);
        }

    }
}